import os
import subprocess
from _md5 import md5
import multiprocessing

from alibabacloud_ecs20140526.client import Client as Ecs20140526Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_ecs20140526 import models as ecs_20140526_models
from alibabacloud_tea_util import models as util_models

if __name__ == '__main__':
    globals()
    access_key_id = 'LTAI5tRrwypSzHqdoiF7FDdh'
    access_key_secret = 'wE0YYHxEnB89IHyN4WKCPuEwyzyMl4'
    config = open_api_models.Config(
        # 您的AccessKey ID,
        access_key_id=access_key_id,
        # 您的AccessKey Secret,
        access_key_secret=access_key_secret
    )
    # 访问的域名
    config.endpoint = f'ecs.ap-northeast-1.aliyuncs.com'
    EcsClient = Ecs20140526Client(config)
    runtime = util_models.RuntimeOptions()
    # 获取所有可用区列表
    describe_regions_request = ecs_20140526_models.DescribeRegionsRequest()
    DescribeRegionsResponse = EcsClient.describe_regions_with_options(describe_regions_request, runtime)
    # 可用区列表
    regions = DescribeRegionsResponse.body.regions.region
    regions_dict = {}
    overseas_regions_dict = {}
    select_regions_dict = {}
    for region in regions:
        # region转成字典
        regions_dict[region.region_id] = {
            'region_id': region.region_id,
            'region_endpoint': region.region_endpoint,
            'local_name': region.local_name,
        }
        if region.region_id[:2] != 'cn':
            overseas_regions_dict[region.region_id] = regions_dict[region.region_id]
    print(regions_dict)

